%remcheckerboard.m
%to remove checkerboard artifacts
NSI=size(M0,1);
[XC,YC]=meshgrid((1:NSI)-NSI/2-1);
WRC=sqrt(XC.^2+YC.^2)/(pseq.fovcm);
MRC=WRC<(1.128*2.5);
r2g=MRC.*fftshift(fft2(fftshift(R2e)));
m0g=MRC.*fftshift(fft2(fftshift(M0)));

[X256,Y256]=meshgrid(((1:256)-129)/(pseq.fovcm));
ps1=(256-NSI)/2;
r21=[zeros(ps1,256);zeros(NSI,ps1) r2g zeros(NSI,ps1);zeros(ps1,256)];
m01=[zeros(ps1,256);zeros(NSI,ps1) m0g zeros(NSI,ps1);zeros(ps1,256)];
R2g=fftshift(ifft2(fftshift(r21)));
M0g=fftshift(ifft2(fftshift(m01)));
figure(1);subplot(1,2,1);imagesc(abs(R2g));axis image
subplot(1,2,2);imagesc(abs(M0g));axis image